﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.ComponentModel;
namespace CoreData
{
    public class Product_Attribute
    {
        public long ID { get; set; }
        
        public long ProductID { get; set; }
        [Description("Thuộc tính")]
        public long AttributeID { get; set; }
        [Description("Giá trị")]
        public string Value { get; set; }
        [Description("Mô tả")]
        public string Note { get; set; }
        [Description("Sử dụng")]
        public bool Active { get; set; }

        public Product_Attribute()
        {
            Value = "";
            Note = "";
        }

        static Product_Attribute DynamicCast<T>(object row_data, object row_header) where T : Product_Attribute
        {
            // row_data : DataRow
            // row_header : DataColumnCollection
            Product_Attribute ret = new Product_Attribute();
            DataRow dt = (DataRow)row_data;

            foreach (DataColumn column in (DataColumnCollection)row_header)
            {
                switch (column.ColumnName)
                {
                    case "ID":
                        ret.ID = ConvertObject.ToLong(dt[column]);
                        break;
                    case "ProductID":
                        ret.ProductID = ConvertObject.ToLong(dt[column]);
                        break;
                    case "AttributeID":
                        ret.AttributeID = ConvertObject.ToLong(dt[column]);
                        break;
                    case "Value":
                        ret.Value = ConvertObject.ToString(dt[column]);
                        break;
                    case "Note":
                        ret.Note = ConvertObject.ToString(dt[column]);
                        break;
                    case "Active":
                        ret.Active = ConvertObject.ToBool(dt[column]);
                        break;

                    default:
                        break;
                }
            }

            return ret;
        }

    }
}
